<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../css/sousuo.css" type="text/css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!--    <link rel="stylesheet" href="style.css">-->
</head>
<body>
<div th:include="common/inc"></div>
    <div style="width: 1000px;margin: 0 auto;margin-bottom: 20px;border-bottom: 1px solid #8d92a1;">
        <div class="search bar1">
            <div id="form1">
                <input type="text" id="positionName" placeholder="请输入您要搜索的内容...">
                <button value="查询" onclick="serach()"></button>
            </div>
        </div>
        <div id="showHangyye" class="lx"></div>
        <div id="showXueli" class="lx"></div>
        <div id="showXinzi" class="lx"></div>
        <div id="showJingyan" class="lx"></div>
        <div id="showGuimo" class="lx"></div>
        <div id="showRongzi" class="lx" style="border-bottom: 0px;"></div>
    </div>
    <div id="showZhiwei"></div>
</body>
<script type="text/javascript">
    var dataIds = "";
    var tids1 = "";
    var tids2 = "";
    var tids3 = "";
    var tids4 = "";
    var tids5 = "";
    var tids6 = "";
    var tids7 = "";
    var tids8 = "";
    $(function() {
        serach();
        getType();
    })
    function getType() {
        $.ajax({
            url:"/data/getData",
            type:"get",
            dataType:"json",
            success:function(data){
                var str2="公司类型：<a href='javascript:setType(2,-2)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                var str4="学历要求：<a href='javascript:setType(4,-4)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                var str5="薪资待遇：<a href='javascript:setType(5,-5)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                var str6="工作经验：<a href='javascript:setType(6,-6)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                var str7="公司规模：<a href='javascript:setType(7,-7)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                var str8="融资阶段：<a href='javascript:setType(8,-8)'>全部</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                for(var i =0; i < data.length; i++){
                    if(data[i].dataRole == "公司类型"){
                        str2 +="<a href ='javascript:setType(2,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }
                    if(data[i].dataRole == "公司规模"){
                        str7 +="<a href ='javascript:setType(7,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }if(data[i].dataRole == "融资阶段"){
                        str8 +="<a href ='javascript:setType(8,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }if(data[i].dataRole == "学历要求"){
                        str4 +="<a href ='javascript:setType(4,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }if(data[i].dataRole == "工作经验"){
                        str6 +="<a href ='javascript:setType(6,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }if(data[i].dataRole == "薪资待遇"){
                        str5 +="<a href ='javascript:setType(5,"+data[i].dataId+")'>" + data[i].dataName+"</a>&nbsp;&nbsp;&nbsp;&nbsp;"

                    }
                }
                $("#showHangyye").html(str2);
                $("#showXueli").html(str4);
                $("#showXinzi").html(str5);
                $("#showJingyan").html(str6);
                $("#showGuimo").html(str7);
                $("#showRongzi").html(str8);
            },error:function(){
                alert("查询类型失败");
            }
        })
    }
    function setType(num,typeid) {
        var tids="";
        console.log(num+";"+typeid);
        if(num == 1){
            if(typeid == -1 ||typeid == "-1" ){
                tids1 = "";
            }else{
                tids1 = typeid;
            }
        }
        if(num == 2){
            if(typeid == -2 ||typeid == "-2"){
                tids2 = "";
            }else{
                tids2 = typeid;
            }
        }
        if(num == 3){
            if(typeid == -3 ||typeid == "-3"){
                tids3 = "";
            }else{
                tids3 = typeid;
            }
        }
        if(num == 4){
            if(typeid == -4 ||typeid == "-4"){
                tids4 = "";
            }else{
                tids4 = typeid;
            }
        }if(num == 5){
            if(typeid == -5 ||typeid == "-5"){
                tids5 = "";
            }else{
                tids5 = typeid;
            }
        }
        if(num == 6){
            if(typeid == -6 ||typeid == "-6"){
                tids6 = "";
            }else{
                tids6 = typeid;
            }
        }
        if(num == 7){
            if(typeid == -7 ||typeid == "-7"){
                tids7 = "";
            }else{
                tids7 = typeid;
            }
        }
        if(num == 8){
            if(typeid == -8 ||typeid == "-8"){
                tids8 = "";
            }else{
                tids8 = typeid;
            }
        }
        if(tids1 != "" && tids1 != null){
            tids += "," + tids1;
        }
        if(tids2 != "" && tids2 != null){
            tids += "," + tids2;
        }
        if(tids3 != "" && tids3 != null){
            tids += "," + tids3;
        }
        if(tids4 != "" && tids4 != null){
            tids += "," + tids4;
        }
        if(tids5 != "" && tids5 != null){
            tids += "," + tids5;
        }
        if(tids6 != "" && tids6 != null){
            tids += "," + tids6;
        }
        if(tids7 != "" && tids7 != null){
            tids += "," + tids7;
        }
        if(tids8 != "" && tids8 != null){
            tids += "," + tids8;
        }
        dataIds = tids.substring(1);
        serach();
    }
    function serach() {
        var positionName = $("#positionName").val();
        console.log("dataIds:"+dataIds+";positionName:"+positionName);
        $.ajax({
            url:"/pquery/positionList?dataIds="+dataIds+"&positionName="+positionName,
            type:"post",
            dataType:"html",
            success:function(data){
                $("#showZhiwei").html(data);
            },error:function(){
                alert("查询失败");
            }
        })
    }
</script>
</html>